package de.poketradeshop.ui.controller;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;

import de.poketradeshop.database.DatabaseService;
import de.poketradeshop.ui.model.Pokemon;
import de.poketradeshop.ui.model.PokemonContainer;

//not used in this version: neccessary for admin area

@Named
@SessionScoped
public class PokemonController implements Serializable {

	@Inject
	private DatabaseService databaseService;

	@Inject
	private PokemonContainer pokemonContainer;

	/**
	 * initiate pokemon/show all pokemons
	 */
	public void initiatePokemons() {
		try {
			//set pokemon container an fill with pokemon from database
			List<Pokemon> allPokemons = databaseService.getAllPokemons();
			pokemonContainer.setPokemons(allPokemons);

		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	public PokemonContainer getContainer() {
		return pokemonContainer;
	}

	public void setContainer(PokemonContainer container) {
		this.pokemonContainer = container;
	}

}
